package com.wxy.demo.client;

import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;
import org.apache.axis2.transport.http.HTTPConstants;

import javax.xml.namespace.QName;
import java.util.Arrays;

/**
 * @author wangxiaoyuan
 * 2021/3/19 15:39
 **/
public class Axis2Client {
    public static void main(String[] args) throws AxisFault {
        RPCServiceClient serviceClient = new RPCServiceClient();
        Options options = serviceClient.getOptions();
        EndpointReference targetEPR = new EndpointReference("http://localhost:8089/myservice?wsdl");
        //确定目标服务地址
        options.setTo(targetEPR);
        QName qName = new QName("http://com.soft.ws/my", "authorization");
        Object[] parameters = new Object[]{"admin", "123456"};
        Class[] returnTypes = new Class[]{String.class};
        Object[] result = serviceClient.invokeBlocking(qName, parameters, returnTypes);
        System.out.println(Arrays.toString(result));
    }
}
